Type.registerNamespace("AjaxControlToolkit");
AjaxControlToolkit.ToggleButtonBehavior = function(c) {
	var b = null, a = this;
	AjaxControlToolkit.ToggleButtonBehavior.initializeBase(a, [c]);
	a._idDecoration = "_ToggleButton";
	a._ImageWidth = b;
	a._ImageHeight = b;
	a._UncheckedImageUrl = b;
	a._CheckedImageUrl = b;
	a._DisabledUncheckedImageUrl = b;
	a._DisabledCheckedImageUrl = b;
	a._CheckedImageOverUrl = b;
	a._UncheckedImageOverUrl = b;
	a._UncheckedImageAlternateText = b;
	a._CheckedImageAlternateText = b;
	a._CheckedImageOverAlternateText = b;
	a._UncheckedImageOverAlternateText = b;
	a._decoyElement = b;
	a._decoyElementClickHandler = b;
	a._checkChangedHandler = b;
	a._divContent = b;
	a._clickHandler = b;
	a._decoyElementMouseOverHandler = b;
	a._decoyElementMouseOutHandler = b
};
AjaxControlToolkit.ToggleButtonBehavior.prototype = {
	initialize: function() {
		var a = this;
		AjaxControlToolkit.ToggleButtonBehavior.callBaseMethod(a, "initialize");
		var b = a.get_element();
		a._divContent = document.createElement("div");
		a._divContent.style.position = "relative";
		a._decoyElement = document.createElement("a");
		b.parentNode.insertBefore(a._divContent, b);
		a._decoyElement.id = b.id + a._idDecoration;
		a._decoyElement.href = "";
		a._divContent.appendChild(a._decoyElement);
		b.style.visibility = "hidden";
		var c = a._decoyElement.style;
		c.position = "absolute";
		c.left = "0px";
		c.top = "0px";
		c.width = a._ImageWidth + "px";
		c.height = a._ImageHeight + "px";
		c.fontSize = a._ImageHeight + "px";
		c.backgroundRepeat = "no-repeat";
		a._onClick();
		a._clickHandler = Function.createDelegate(a, a._onClick);
		a._checkChangedHandler = Function.createDelegate(a, a._onClick);
		a._decoyElementClickHandler = Function.createDelegate(a, a._onDecoyElementClick);
		a._decoyElementMouseOverHandler = Function.createDelegate(a, a._onDecoyElementMouseOver);
		a._decoyElementMouseOutHandler = Function.createDelegate(a, a._onDecoyElementMouseOut);
		$addHandler(b, "click", a._clickHandler);
		$addHandler(b, "change", a._checkChangedHandler);
		$addHandler(a._decoyElement, "click", a._decoyElementClickHandler);
		$addHandler(a._decoyElement, "mouseover", a._decoyElementMouseOverHandler);
		$addHandler(a._decoyElement, "mouseout", a._decoyElementMouseOutHandler);
		if (Sys.Browser.agent === Sys.Browser.InternetExplorer) {
			var d = a._divContent.parentNode.getElementsByTagName("label");
			for (i = 0; i < d.length; i++)
				if (b.id == d[i].htmlFor) d[i].htmlFor = b.id + a._idDecoration
			}
	},
	dispose: function() {
		var b = null, a = this;
		if (a._decoyElementClickHandler) {
			$removeHandler(a._decoyElement, "click", a._decoyElementClickHandler);
			a._decoyElementClickHandler = b
		}
		if (a._checkChangedHandler) {
			$removeHandler(a.get_element(), "change", a._checkChangedHandler);
			a._checkChangedHandler = b
		}
		if (a._clickHandler) {
			$removeHandler(a.get_element(), "click", a._clickHandler);
			a._clickHandler = b
		}
		if (a._decoyElementMouseOverHandler) {
			$removeHandler(a._decoyElement, "mouseover", a._decoyElementMouseOverHandler);
			a._decoyElementMouseOverHandler = b
		}
		if (a._decoyElementMouseOutHandler) {
			$removeHandler(a._decoyElement, "mouseout", a._decoyElementMouseOutHandler);
			a._decoyElementMouseOutHandler = b
		}
		AjaxControlToolkit.ToggleButtonBehavior.callBaseMethod(a, "dispose")
	},
	_onClick: function() {
		var a = this;
		if (a.get_element().checked) {
			a._decoyElement.style.backgroundImage = "url(" + (a.get_element().disabled ? a.get_DisabledCheckedImageUrl() : a._CheckedImageUrl) + ")";
			if (a._CheckedImageAlternateText) 
				a._decoyElement.title = a._CheckedImageAlternateText
		}
		else {
			a._decoyElement.style.backgroundImage = "url(" + (a.get_element().disabled ? a.get_DisabledUncheckedImageUrl() : a._UncheckedImageUrl) + ")";
			if (a._UncheckedImageAlternateText)
				a._decoyElement.title = a._UncheckedImageAlternateText
		}
	},
	_onDecoyElementClick: function(a) {
		this.get_element().click();
		a.preventDefault();
		return false
	},
	_onDecoyElementMouseOver: function(b) {
		var a = this, b = a.get_element();
		if (b && !b.disabled)
			if (b.checked && a._CheckedImageOverUrl) {
				a._decoyElement.style.backgroundImage = "url(" + a._CheckedImageOverUrl + ")";
				if (a._CheckedImageOverAlternateText)
					a._decoyElement.title = a._CheckedImageOverAlternateText
			}
			else if (!b.checked && a._UncheckedImageOverUrl) {
			a._decoyElement.style.backgroundImage = "url(" + a._UncheckedImageOverUrl + ")";
			if (a._UncheckedImageOverAlternateText)
				a._decoyElement.title = a._UncheckedImageOverAlternateText
		}
	},
	_onDecoyElementMouseOut: function() {
		this._onClick()
	},
	get_ImageWidth: function() {
		return this._ImageWidth
	},
	set_ImageWidth: function(a) {
		if (this._ImageWidth != a) {
			this._ImageWidth = a;
			this.raisePropertyChanged("ImageWidth")
		}
	},
	get_ImageHeight: function() {
		return this._ImageHeight
	},
	set_ImageHeight: function(a) {
		if (this._ImageHeight != a) {
			this._ImageHeight = a;
			this.raisePropertyChanged("ImageHeight")
		}
	},
	get_UncheckedImageUrl: function() {
		return this._UncheckedImageUrl
	},
	set_UncheckedImageUrl: function(a) {
		if (this._UncheckedImageUrl != a) {
			this._UncheckedImageUrl = a;
			this.raisePropertyChanged("UncheckedImageUrl")
		}
	},
	get_CheckedImageUrl: function() {
		return this._CheckedImageUrl
	},
	set_CheckedImageUrl: function(a) {
		if (this._CheckedImageUrl != a) {
			this._CheckedImageUrl = a;
			this.raisePropertyChanged("CheckedImageUrl")
		}
	},
	get_DisabledUncheckedImageUrl: function() {
		return this._DisabledUncheckedImageUrl != undefined ? this._DisabledUncheckedImageUrl : this._UncheckedImageUrl
	},
	set_DisabledUncheckedImageUrl: function(a) {
		if (this._DisabledUncheckedImageUrl != a) {
			this._DisabledUncheckedImageUrl = a;
			this.raisePropertyChanged("DisabledUncheckedImageUrl")
		}
	},
	get_DisabledCheckedImageUrl: function() {
		return this._DisabledUncheckedImageUrl != undefined ? this._DisabledCheckedImageUrl : this._CheckedImageUrl
	},
	set_DisabledCheckedImageUrl: function(a) {
		if (this._DisabledCheckedImageUrl != a) {
			this._DisabledCheckedImageUrl = a;
			this.raisePropertyChanged("DisabledCheckedImageUrl")
		}
	},
	get_CheckedImageOverUrl: function() {
		return this._CheckedImageOverUrl
	},
	set_CheckedImageOverUrl: function(a) {
		if (this._CheckedImageOverUrl != a) {
			this._CheckedImageOverUrl = a;
			this.raisePropertyChanged("CheckedImageOverUrl")
		}
	},
	get_UncheckedImageOverUrl: function() {
		return this._UncheckedImageOverUrl
	},
	set_UncheckedImageOverUrl: function(a) {
		if (this._UncheckedImageOverUrl != a) {
			this._UncheckedImageOverUrl = a;
			this.raisePropertyChanged("UncheckedImageOverUrl")
		}
	},
	get_UncheckedImageAlternateText: function() {
		return this._UncheckedImageAlternateText
	},
	set_UncheckedImageAlternateText: function(a) {
		if (this._UncheckedImageAlternateText != a) {
			this._UncheckedImageAlternateText = a;
			this.raisePropertyChanged("UncheckedImageAlternateText")
		}
	},
	get_CheckedImageAlternateText: function() {
		return this._CheckedImageAlternateText
	},
	set_CheckedImageAlternateText: function(a) {
		if (this._CheckedImageAlternateText != a) {
			this._CheckedImageAlternateText = a;
			this.raisePropertyChanged("CheckedImageAlternateText")
		}
	},
	get_CheckedImageOverAlternateText: function() {
		return this._CheckedImageOverAlternateText
	},
	set_CheckedImageOverAlternateText: function(a) {
		if (this._CheckedImageOverAlternateText != a) {
			this._CheckedImageOverAlternateText = a;
			this.raisePropertyChanged("CheckedImageOverAlternateText")
		}
	},
	get_UncheckedImageOverAlternateText: function() {
		return this._UncheckedImageOverAlternateText
	},
	set_UncheckedImageOverAlternateText: function(a) {
		if (this._UncheckedImageOverAlternateText != a) {
			this._UncheckedImageOverAlternateText = a;
			this.raisePropertyChanged("UncheckedImageOverAlternateText")
		}
	}
};
				
AjaxControlToolkit.ToggleButtonBehavior.registerClass("AjaxControlToolkit.ToggleButtonBehavior",AjaxControlToolkit.BehaviorBase);